<!doctype html>
<html>
{include file="head.html"}

<body>
  <div class="fullscreen">
        <div class="scroll_content">
            <div class="topfixed">
				<div class="t_left"><a href="/index.php"><i class="back"></i></a></div>
                <div class="t_main">购物车</div>
            </div>
            <div class="paddingheight"></div>
			 
            <ul class="cart_new_list clearfix">
            {foreach item=c from=$ymcart}
                <li url="/index.php?m=ymdian_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl">{$c.title}（夜猫寝长）</span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=ymdian_order_cart&a=clear&shopid={$c.id}">清空</a></span></div>
                    {foreach item=p from=$c.products}
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="{$p.imgurl|images_site}.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit">{$p.title}</div>

                            <div class="info">

                                <p class="fl">
                                {if $p.lower_price}
                                    <b class="red">￥{$p.lower_price}</b>
                                    <del>￥{$p.price}</del>
                                 {else}
                                 <b class="red">￥{$p.price}</b>
                                 {/if}   
                                </p>
 
                                <p class="fr">
                                    <span class="cart_num"  object_id="{$p.object_id}" shopid="{$c.id}" productid="{$p.productid}">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="{$p.amount}" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    {/foreach}
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num">{$c.total_num}</a>件，合计:<b class="red">￥<a class="total_money">{$c.total_money}</a></b></span>
                        <span class="fr"><a href="/index.php?m=ymdian_order&a=confirm&shopid={$c.id}" class="buy">去结算</a> </span>
                    </div>
                </li>
                {/foreach}
                {foreach item=c from=$kdcart}
                <li url="/index.php?m=koudai_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl">66口袋</span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=koudai_order_cart&a=clear&shopid={$c.id}">清空</a></span></div>
                    {foreach item=p from=$c.products}
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="{$p.imgurl|images_site}.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit">{$p.title}</div>

                            <div class="info">

                                <p class="fl">
                                {if $p.lower_price}
                                    <b class="red">￥{$p.lower_price}</b>
                                    <del>￥{$p.price}</del>
                                 {else}
                                 <b class="red">￥{$p.price}</b>
                                 {/if}   
                                </p>

                                <p class="fr">
                                    <span class="cart_num"  object_id="{$p.object_id}" shopid="{$c.id}" productid="{$p.productid}">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="{$p.amount}" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    {/foreach}
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num">{$c.total_num}</a>件，合计:<b class="red">￥<a class="total_money">{$c.total_money}</a></b></span>
                        <span class="fr"><a href="/index.php?m=koudai_order&a=confirm&shopid={$c.id}" class="buy">去结算</a> </span>
                    </div>
                </li>
                {/foreach}
                {foreach item=c from=$shopcart}
                <li url="/index.php?m=shop_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl">{$c.shopname}</span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=shop_order_cart&a=clear&shopid={$c.id}">清空</a></span></div>
                    {foreach item=p from=$c.products}
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="{$p.imgurl|images_site}.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit">{$p.title}</div>

                            <div class="info">

                                <p class="fl">
                                {if $p.lower_price}
                                    <b class="red">￥{$p.lower_price}</b>
                                    <del>￥{$p.price}</del>
                                 {else}
                                 <b class="red">￥{$p.price}</b>
                                 {/if}   
                                </p>

                                <p class="fr">
                                    <span class="cart_num"  object_id="{$p.object_id}" shopid="{$c.shopid}" productid="{$p.productid}">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="{$p.amount}" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    {/foreach}
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num">{$c.total_num}</a>件，合计:<b class="red">￥<a class="total_money">{$c.total_money}</a></b></span>
                        <span class="fr"><a href="/index.php?m=shop_order&a=confirm&shopid={$c.shopid}" class="buy">去结算</a> </span>
                    </div>
                </li>
                {/foreach}
            </ul>
        </div>
    </div>
<script>
//数量加减
 
$(function(){
	$(".cart_clear").on("click",function(){
		var obj=$(this);
		$.get(obj.attr("url"),function(data){
			if(data.error){
				
			}else{
				obj.parents("li").remove();;
			}
		},"json")
	});
	
	$(document).on("click",".DisDe",function(){
		var obj=$(this);
		var p=obj.parents(".cart_num");
		var v=parseInt(p.find(".Amount").val());
		v=v-1;
		var shop=$(this).parents("li");
		if(v>=0){
			$.get(shop.attr("url"),{object_id:p.attr("object_id"),shopid:p.attr("shopid"),productid:p.attr('productid'),amount:v},function(data){
				if(data.error){
					alert(data.message);
				}else{
					if(v==0){
						obj.parents(".list").remove();
						shop.find(".total_num").html(data.data.num);
						shop.find(".total_money").html(data.data.total_money);
					}else{
						p.find(".Amount").val(v);
						shop.find(".total_num").html(data.data.num);
						shop.find(".total_money").html(data.data.total_money);
						var ptm=obj.parents("li").find(".p_total_money");
						var pprice=obj.parents("li").find(".p_price").html();
						ptm.html(parseInt(pprice)*v);
					}
				 
				 
				}
			},"json")
		}else{
			skyToast("数量不能少于1件");
		}
	});
	
	$(document).on("click",".Increase",function(){
		var obj=$(this);
		var p=obj.parents(".cart_num");
		var v=parseInt(p.find(".Amount").val());
		var nv=v+1;
		var shop=$(this).parents("li");
		$.get(shop.attr("url"),{object_id:p.attr("object_id"),shopid:p.attr("shopid"),productid:p.attr('productid'),amount:nv},function(data){
			if(data.error){
				alert(data.message);
			}else{
				p.find(".Amount").val(nv);
				shop.find(".total_num").html(data.data.num);
					shop.find(".total_money").html(data.data.total_money);
				var ptm=obj.parents("li").find(".p_total_money");
				var pprice=obj.parents("li").find(".p_price").html();
				ptm.html(parseInt(pprice)*nv);
			 
			}
		},"json")
		
		
	});
	
});
</script>
{assign var="botnav" value="cart"}
 {include file="botnav.html"}
 {include file="footer.html"} 
</body>
</html>
